<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="<%=request.getContextPath()%>/resource/css/index3.css" rel="stylesheet">
<script type="text/javascript" src="<%=request.getContextPath()%>/resource/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
	
	//换页
	function goPage(pageNum) {
		$("[name='pageNum']").val(pageNum);
		$("form").submit();
	}
	
	//出租
	function chu(id) {
		location="<%=request.getContextPath()%>/chu?id="+id;
	}
	
	//退租
	function tui(id) {
		location="<%=request.getContextPath()%>/tui?id="+id;
	}
	
	//删除
	function del(id) {
		if(confirm("你确定删除吗")){
			location="<%=request.getContextPath()%>/del?id="+id;
		}
		
	}
	
	//添加房屋
	function add() {
		location="<%=request.getContextPath()%>/toAdd";
	}
	
	//添加设施
	function addPei(id) {
		location="<%=request.getContextPath()%>/toAddPei?id="+id;
	}
</script>
</head>
<body>
	<center><form action="<%=request.getContextPath()%>/list" method="post">
			<input type="hidden" name="pageNum">
		小区名称：<input name="name" value="${tem.name }" placeholder="请输入小区名称">
		出租状态：<select name="status">
			<option value="">==请选择==</option>
			<option value="0" ${tem.status eq '0'?'selected':'' }>待租</option>
			<option value="1" ${tem.status eq '1'?'selected':'' }>已租</option>
		</select>
		装修情况：<select name="typ">
			<option value="">==请选择==</option>
			<c:forEach items="<%=com.yanshibo.house01_bean.bean.Types.values()%>" var="d">
				<option value="${d.ordinal }" ${tem.typ == d.ordinal?'selected':'' }>${d.val }</option>
			</c:forEach>
		</select>
		挂牌时间：<input name="listingTime" value="${tem.listingTime }">
		<input type="submit" value="查询">
		
	</form></center>
	<table>
		<tr>
			<td>编号</td>
			<td>小区名称</td>
			<td>单元楼</td>
			<td>门牌号</td>
			<td>实景图</td>
			<td>状态</td>
			<td>挂牌时间</td>
			<td>出租时间</td>
			<td>户型</td>
			<td>装修情况</td>
			<td>配套设施</td>
			<td>操作</td>
		</tr>
		<c:forEach items="${info.list }" var="d">
			<tr>
				<td>${d.id }</td>
				<td>${d.name }</td>
				<td>${d.building }</td>
				<td>${d.number }</td>
				<td>
					<c:if test="${d.picture!=null }">
						<img alt="imgs" src="${d.picture }" width="100px">
					</c:if>
				</td>
				<td>${d.status eq '0'?'待租':'已租' }</td>
				<td><fmt:formatDate value="${d.listingTime }" pattern="yyyy-MM-dd"/></td>
				<td><fmt:formatDate value="${d.rentalTime }" pattern="yyyy-MM-dd"/></td>
				<td>${d.lei.name }</td>
				<td>${d.typ.val }</td>
				<td>
					<c:forEach items="${d.pts }" var="p" varStatus="v">
						${p.name }
						<c:if test="${!v.last }">
							、
						</c:if>
					</c:forEach>
				</td>
				<td>
				<input type="button" value="添加" onclick="add()">
					<c:if test="${d.status eq '0'}">
						<input type="button" value="删除" onclick="del(${d.id })">
						<input type="button" value="出租" onclick="chu(${d.id })">
					</c:if>
					<c:if test="${d.status eq '1'}">
						<input type="button" value="退租" onclick="tui(${d.id })">
					</c:if>
					<input type="button" value="新增设施" onclick="addPei(${d.id })">
				</td>
			</tr>
		</c:forEach>
		<tr>
			<td colspan="20">
				
				当前是${info.pageNum }/${info.pages }页
				
				<c:forEach items="${info.navigatepageNums }"  var="pageNum">
				<a href="javaScript:goPage(${pageNum })">${pageNum }</a>
			</c:forEach>
			</td>
		</tr>
	</table>

</body>
</html>